enum LogColor {
  Success = 'green',
  Warn = 'orange',
  Error = 'red',
  Info = 'gray'
}

enum LogTitle {
  Success = 'success',
  Warn = 'warning',
  Error = 'error',
  Info = 'info'
}

const log = (...arg: any[]) => {
  let type: LogColor = LogColor.Success
  let title: LogTitle = LogTitle.Success
  let desc: string = 'desc'

  let _arg: any[] = []
  // 如果只有一个值，这个值认为是需要打印的内容
  if (arg.length > 1) {
    type = arg[0]
    _arg = arg.slice(1)
  }
  if (arg.length > 2) {
    title = arg[1]
    _arg = arg.slice(2)
  }
  if (arg.length > 3) {
    desc = arg[2]
    _arg = arg.slice(3)
  }
  console.log(
    `%c${title}%c[${desc}]%c`,
    `background: ${type};color:white;padding:2px;border-radius: 3px 0 0 3px`,
    'border: 1px solid #666; padding:1px; border-radius: 0 3px 3px 0',
    'background: transparent',
    ..._arg
  )
}

export const DLog = {
  Success: (...arg: any[]) => {
    log(LogColor.Success, LogTitle.Success, ...arg)
  },
  Warn: (...arg: any[]) => {
    log(LogColor.Warn, LogTitle.Warn, ...arg)
  },
  Error: (...arg: any[]) => {
    log(LogColor.Error, LogTitle.Error, ...arg)
  },
  Info: (...arg: any[]) => {
    log(LogColor.Info, LogTitle.Info, ...arg)
  }
}
